using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Spinning.Spinning.Interface;
using Spinning.Spinning.Entity;
using Box2D.XNA;

namespace Spinning.Spinning.Unitity
{
    class PhysicConnectManager : IUpdateHandler
    {
        List<PhysicConnector> connectors;

        public PhysicConnectManager() {
            connectors = new List<PhysicConnector>();
        }

        public void AddPhysicConnector(PhysicConnector physicConnector)
        {
            connectors.Add(physicConnector);
        }

        public void RemovePhysicConnector(PhysicConnector physicConnector) {
            connectors.Remove(physicConnector);
        }

        public void OnUpdate(GameTime gameTime) {
            foreach (PhysicConnector p in connectors)
                p.OnUpdate(gameTime);
        }

        public Sprite FindSpriteByBody(Body body)
        {
            Sprite s = null;
            foreach (PhysicConnector p in connectors) {
                if (p.Body == body)
                    s = p.Actor;
            }
            return s;
        }

    }
}
